<%@page import="java.sql.ResultSet"%>
<%@page import="Model.Professor"%>
<%@include file="includes/header.jsp" %>

<div class="row-fluid">
    <div class="span12">
        <h1>Turmas
        </h1>
        <hr/>
        <div id="infoi"></div>
        <table class="table table-bordered table-striped table-condensed" id="dataTable">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Curso</th>
                    <th>Sala</th>
                    <th>Disciplina</th>
                    <th>Dia 1 / Horario</th>
                    <th>Dia 2 / Horario</th>
                    <th>Dia 3 / Horario</th>                    
                </tr>
            </thead>
            <tbody>
                <%
                    ResultSet solic = s.getTurmasTable();
                    while (solic.next()) {
                        out.println("<tr>");
                        out.println("<td>" + solic.getString("id") + "</td>");
                        out.println("<td>" + solic.getString("curso") + "</td>");
                        out.println("<td>" + solic.getString("sala") + "</td>");
                        out.println("<td>" + solic.getString("disciplina") + "</td>");
                        
                        
                        String hora1 = (solic.getString("hora1").equals("null")) ? "-" : solic.getString("hora1");
                        String hora2 = (solic.getString("hora2").equals("null")) ? "-" : solic.getString("hora2");
                        String hora3 = (solic.getString("hora3").equals("null")) ? "-" : solic.getString("hora3");
                        
                        String dia1 = (solic.getString("dia1") == null) ? "-" : solic.getString("dia1");
                        String dia2 = (solic.getString("dia2") == null) ? "-" : solic.getString("dia2");
                        String dia3 = (solic.getString("dia3") == null) ? "-" : solic.getString("dia3");

                        switch (Integer.parseInt(dia1)) {
                            case 1:
                                dia1 = "Segunda-feira";
                                break;
                            case 2:
                                dia1 = "Terca-feira";
                                break;
                            case 3:
                                dia1 = "Quarta-feira";
                                break;
                            case 4:
                                dia1 = "Quinta-feira";
                                break;
                            case 5:
                                dia1 = "Sexta-feira";
                                break;
                            default:
                                dia1 = "-";
                                break;
                        }
                        if (!dia2.equals("-")) {
                            switch (Integer.parseInt(dia2)) {
                                case 1:
                                    dia2 = "Segunda-feira";
                                    break;
                                case 2:
                                    dia2 = "Terca-feira";
                                    break;
                                case 3:
                                    dia2 = "Quarta-feira";
                                    break;
                                case 4:
                                    dia2 = "Quinta-feira";
                                    break;
                                case 5:
                                    dia2 = "Sexta-feira";
                                    break;
                                default:
                                    dia2 = "-";
                                    break;
                            }
                        }
                        if (!dia3.equals("-")) {
                            switch (Integer.parseInt(dia3)) {
                                case 1:
                                    dia3 = "Segunda-feira";
                                    break;
                                case 2:
                                    dia3 = "Terca-feira";
                                    break;
                                case 3:
                                    dia3 = "Quarta-feira";
                                    break;
                                case 4:
                                    dia3 = "Quinta-feira";
                                    break;
                                case 5:
                                    dia3 = "Sexta-feira";
                                    break;
                                default:
                                    dia3 = "-";
                                    break;
                            }
                        }

                        out.println("<td>" + dia1 + " / " + hora1 + "</td>");
                        out.println("<td>" + dia2 + " / " + hora2 + "</td>");
                        out.println("<td>" + dia3 + " / " + hora3 + "</td>");                       
                        out.println("</tr>");
                    }
                %>
            </tbody>
        </table>

    </div>
</div>
<%@include file="includes/footer.jsp" %>

